#ifndef SOCKETMANAGER_H
#define SOCKETMANAGER_H

#include <QTcpSocket>
#include <QJsonObject>
#include <QByteArray>
#include <QJsonDocument>
#include "protocol.h"
#include <QJsonParseError>

class SocketManager : public QObject
{
    Q_OBJECT

public:
    static SocketManager* instance();

    QTcpSocket* getsocket();

    void connectToServer();

signals:
    void loginResponse(QJsonObject);
    void registerResponse(QJsonObject);
    void chatMessage(QJsonObject);
    void serverBroadcast(QJsonObject);

private slots:
    void onReadyRead();

private:
    SocketManager(QObject* parent = nullptr);
    ~SocketManager()=default;

    SocketManager(const SocketManager&)=delete;
    SocketManager& operator=(const SocketManager&)=delete;

    QTcpSocket* socket;
};



#endif // SOCKETMANAGER_H
